package com.telit.android.controller;

import com.telit.android.entity.AppHomePageApplication;
import com.telit.android.service.AppPageApplicationService;
import com.telit.common.entity.DataReturn;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * @author zhouyu
 * @description app首页应用接口
 */
@RestController
@RequestMapping("/app-page-application")
@Api(tags = "app首页应用接口", description = "/app-page-application")
public class AppPageApplicationController {

    @Autowired
    private AppPageApplicationService appPageApplicationService;


    @GetMapping("/queryByUserId")
    @ApiOperation("根据用户id查询首页应用")
    public DataReturn queryByUserId(@RequestParam("userRole") String userRole) {
        List<AppHomePageApplication> list = appPageApplicationService.queryByUserId(userRole);
        return DataReturn.ok(list);
    }

    @PostMapping("/updateAppPage")
    @ApiOperation("修改首页应用展示")
    public DataReturn updateAppPage(@RequestBody(required = true) List<AppHomePageApplication> list) {
        appPageApplicationService.updateAppPage(list);
        return DataReturn.ok();
    }

}
